﻿package at.geoathome.text 
{
	import flash.text.TextField;
	import flash.text.TextFormat;
	
	/**
	 * ...
	 * @author Georg Kamptner
	 */
	public class TextFieldGenerator 
	{
		// -- variables & attributes ---------------------------------------------------------------------------
		private static var _instance:TextFieldGenerator;
		
		// -- constructor --------------------------------------------------------------------------------------
		public static function getInstance():TextFieldGenerator
		{
			if (_instance == null)
				_instance = new TextFieldGenerator(new SingletonEnforcer());
			
			return _instance
		}
		
		public function TextFieldGenerator(s:SingletonEnforcer) {}
		
		// -- methods ------------------------------------------------------------------------------------------
		public function getDefaultTextField(text:String, width:int, height:int, font_size:int = 12, border:Boolean = false, backgorund:Boolean = false):TextField
		{
			var tff:TextFormat = new TextFormat();
			tff.size = font_size;
			
			var tf:TextField = new TextField();
			tf.width = width;
			tf.height = height;
			tf.multiline = true;
			tf.wordWrap = true;
			tf.background = backgorund;
			tf.border = border;
			tf.defaultTextFormat = tff;
			tf.text = text;

			return tf;
		}
		
		// -- static methods -----------------------------------------------------------------------------------
		public static function _getDefaultTextField(text:String, width:int, height:int, font_size:int = 12, border:Boolean = false, backgorund:Boolean = false):TextField
		{
			return TextFieldGenerator.getInstance().getDefaultTextField(text, width, height, font_size, border, backgorund);
		}
	}
	
}

class SingletonEnforcer{}